nice_things/fs/readlink.sh
readlink
Since 0.3.0 · Source
import "{ readlink }" from nice_things/fs/readlink.sh
Synopsisreadlink <file>
Configuration
–
Description
Print value of a symbolic link.
Note
This is not a pure sh implementation because it depends on the external
lsutility to read the target of the symlink. This works consistently because the output oflsis strictly specified in POSIX, but it means this function can be slower than most other functions in the framework.
Options
–
Operands<file>: Path to a symbolic link.
Stdin
–
Stdout
The result is printed to stdout, trailed by a line-feed character.
Stderr
–
Exit status
0: Successful completion.22:<file>is not a symbolic link.123: Unexpected error (abort).
Abort
Aborts on unexpected error.
Usage examples
# Read the value of a link
link_target=$(readlink /path/to/link)